<template>
<div id="login" >

  <el-container>
    <el-aside width="300px"> <li style="font-size: 20px">温馨提醒：</li><br/>
      <li>请勿将账号密码告知他人，以免个人信息泄露</li></el-aside>
    <el-container>
      <el-header>登录页面</el-header>
      <el-main>
        <el-row>
          <el-col :span="24"><div class="grid-content bg-purple-light"style="height: 5px"></div></el-col>
        </el-row>
        <el-row>
          <el-col :span="3"><div class="grid-content bg-purple-light" style="font-size: 20px"></div></el-col>
          <el-col :span="3"><div class="grid-content bg-purple"style="font-size: 20px">姓   名：</div></el-col>
          <el-col :span="1"><div class="grid-content bg-purple-light"style="font-size: 20px"></div></el-col>
          <el-col :span="5" ><div class="grid-content bg-purple"style="height: 15px"><el-input  type="text" v-model="name" placeholder="请输入姓名" maxlength="16"></el-input></div></el-col>
          <el-col :span="12"><div class="grid-content bg-purple-light"style="font-size: 20px"> </div></el-col>
        </el-row>
        <el-row>
          <el-col :span="24"><div class="grid-content bg-purple-light"style="height: 5px">  </div></el-col>
        </el-row>
        <el-row>
          <el-col :span="3"><div class="grid-content bg-purple-light" style="font-size: 20px"></div></el-col>
          <el-col :span="3"><div class="grid-content bg-purple"style="font-size: 20px">密   码：</div></el-col>
          <el-col :span="1"><div class="grid-content bg-purple-light"style="font-size: 20px"></div></el-col>
          <el-col :span="5"><div class="grid-content bg-purple"style="font-size: 20px"><el-input type="password" v-model="password" placeholder="请输入密码"   maxlength="16"></el-input></div></el-col>
          <el-col :span="12"><div class="grid-content bg-purple-light"style="font-size: 20px"> </div></el-col>
        </el-row>
        <el-row>
          <el-col :span="24"><div class="grid-content bg-purple-light"style="height: 5px">  </div></el-col>
        </el-row>
        <el-row>
          <el-col :span="4"><div class="grid-content bg-purple-light" style="font-size: 20px"></div></el-col>
          <el-col :span="3"><div class="grid-content bg-purple-light"style="font-size: 20px"> <el-button type="primary" round @click="onSubmit">登录</el-button></div></el-col>
          <el-col :span="3"><div class="grid-content bg-purple-light"style="font-size: 20px"> <el-button type="primary" round>取消</el-button></div></el-col>
          <el-col :span="14"><div class="grid-content bg-purple-light"style="font-size: 20px"> </div></el-col>
        </el-row>
        <el-row>
          <el-col :span="24"><div class="grid-content bg-purple-light"style="height: 5px">  </div></el-col>
        </el-row>

      </el-main>
      <el-footer>版本编号@20191227</el-footer>
    </el-container>
  </el-container>
</div>
</template>
<script>
  import axios from 'axios';
  import router from 'vue-router'
  export default {
    name: "Login",
      data(){
        return {
            name: '孙悟空',
            password: '333'
        }
      },
      components:{
        router
      },
    methods: {

        onSubmit() {
          let that=this
        axios({
            el:"login",
            url:'http://localhost:8080/emp/login',
            method:'post',
            data:JSON.stringify({
                'name':this.name,
                'password':this.password
            }),
            headers:{"Content-Type":"application/json"}
        }).then(r =>{
            if(r.data.code==="200"){
                sessionStorage.setItem("empid",r.data.data.id)
                this.$router.push({path:'/welcome'});

            }else{
                alert("账号或密码错误，登陆失败！")
            }
        })
      },
    }
  }
</script>

<style scoped>
  .el-header, .el-footer {
    background-color: #CED2BA;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    background-color: #E4F8ED;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }


  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }

  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
